(function () {
    "use strict";

    angular.module('core').factory('cartaoPagarService', factory);
    factory.$inject = ['$http', '$q'];

    function factory($http, $q) {

        return {
            get: function (id) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/get', id)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            getAll: function (args) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/getall', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            count: function (args) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/count', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            getParcelaCartaoPagar: function (id) {
                var args = { id: id };
                var deferred = $q.defer();
                $http.post('/cartaoPagar/getParcelaCartaoPagar', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            getAllParcelaCartaoPagar: function (args) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/getAllParcelaCartaoPagar', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            countParcelaCartaoPagar: function (args) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/countParcelaCartaoPagar', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            totalizeParcelaCartaoPagar: function (args) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/totalizeParcelaCartaoPagar', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            getLiquidacaoCartaoPagar: function (id) {
                var args = { id: id };
                var deferred = $q.defer();
                $http.post('/cartaoPagar/getLiquidacaoCartaoPagar', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            getAllLiquidacaoCartaoPagar: function (args) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/getAllLiquidacaoCartaoPagar', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            countLiquidacaoCartaoPagar: function (args) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/countLiquidacaoCartaoPagar', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            prepareNew: function () {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/prepareNew')
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            prepare: function (item) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/prepare', item)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            prepareNewParcelaCartaoPagar: function (item) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/prepareNewParcelaCartaoPagar', item)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            prepareParcelaCartaoPagar: function (item) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/prepareParcelaCartaoPagar', item)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            prepareNewLiquidacaoCartaoPagar: function (item) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/prepareNewLiquidacaoCartaoPagar', item)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            prepareLiquidacaoCartaoPagar: function (item) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/prepareLiquidacaoCartaoPagar', item)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            save: function (item) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/save', item)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            delete: function (id) {
                var args = { id: id };
                var deferred = $q.defer();
                $http.post('/cartaoPagar/delete', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            saveParcelaCartaoPagar: function (item) {
                var deferred = $q.defer();
                $http.post('/cartaoPagar/saveParcelaCartaoPagar', item)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            deleteParcelaCartaoPagar: function (id) {
                var args = { id: id };
                var deferred = $q.defer();
                $http.post('/cartaoPagar/deleteParcelaCartaoPagar', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
        };
    }

})();


